package MuleBackend;

import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;
import javax.swing.border.TitledBorder;
import javax.swing.text.html.StyleSheet;

public class InfoPanel extends JPanel{
	Player player;
	JLabel playerName;
	JLabel playerMoney;
	JLabel playerFood;
	JLabel playerEnergy;
	JLabel playerSmithore;
	JLabel playerMoneyValue;
	JLabel playerFoodValue;
	JLabel playerEnergyValue;
	JLabel playerSmithoreValue;

	/**
	 * Constructor for an information panel
	 * about a player
	 * @param player the player to display information about
	 */
	public InfoPanel(Player player) {
		this.player = player;
		
		setLayout(null);
		setSize(180,100);
		
		Color color = player.getColor();		
		
		//add player
		TitledBorder title = new TitledBorder(player.getName());
		title.setBorder(new LineBorder(color, 2));
		title.setTitleColor(color);
		setBorder(title);
		
		//add resources
		playerMoney = new JLabel("Money :");
		add(playerMoney);
		playerMoney.setBounds(10,20,90,18);
		
		playerFood = new JLabel("Food :");
		add(playerFood);
		playerFood.setBounds(10,38,90,18);
		
		playerEnergy = new JLabel("Energy :");
		add(playerEnergy);
		playerEnergy.setBounds(10,56,90,18);
		
		playerSmithore = new JLabel("Smithore :");
		add(playerSmithore);
		playerSmithore.setBounds(10,74,90,18);
		
		
		
		//add values
		playerMoneyValue = new JLabel(player.getMoney()+"");
		add(playerMoneyValue);
		playerMoneyValue.setBounds(100,20,80,18);
		
		playerFoodValue = new JLabel(player.getFood()+"");
		add(playerFoodValue);
		playerFoodValue.setBounds(100,38,80,18);
		
		playerEnergyValue = new JLabel(player.getEnergy()+"");
		add(playerEnergyValue);
		playerEnergyValue.setBounds(100,56,80,18);
		
		playerSmithoreValue = new JLabel(player.getSmithore()+"");
		add(playerSmithoreValue);
		playerSmithoreValue.setBounds(100,74,80,18);
	}
	
	public InfoPanel(int i) {
		
		setLayout(null);
		setSize(180,100);
		
		//add player
		TitledBorder title = new TitledBorder("Player "+i);
		title.setBorder(new LineBorder(Color.GRAY, 2));
		title.setTitleColor(Color.GRAY);
		setBorder(title);

		playerMoney = new JLabel("Money :");
		playerMoney.setForeground(Color.GRAY);
		add(playerMoney);
		playerMoney.setBounds(10,20,90,18);
		
		playerFood = new JLabel("Food :");
		playerFood.setForeground(Color.GRAY);
		add(playerFood);
		playerFood.setBounds(10,38,90,18);
		
		playerEnergy = new JLabel("Energy :");
		playerEnergy.setForeground(Color.GRAY);
		add(playerEnergy);
		playerEnergy.setBounds(10,56,90,18);
		
		playerSmithore = new JLabel("Smithore :");
		playerSmithore.setForeground(Color.GRAY);
		add(playerSmithore);
		playerSmithore.setBounds(10,74,90,18);
	}
	
	
	/**
	 * Update's the information panel whenever there
	 * is a change in a player's inventory
	 */
	public void updatePanel() {
		playerMoneyValue.setText("" + player.getMoney());
		playerFoodValue.setText("" + player.getFood());
		playerEnergyValue.setText("" + player.getEnergy());
		playerSmithoreValue.setText("" + player.getSmithore());
		repaint();
	}
	
	
	
	
}
